#include <pthread.h>
#include <iostream>
#include <string>
#include <unistd.h>

int count = 1;

std::string Addr(int &c)
{
    char addr[64];
    snprintf(addr, sizeof(addr), "%p", &c);
    return addr;
}
void* routinue1(void* args)
{
    (void)args;
    while(true)
    {
        std::cout << "thread - l, cout = " << count << "[我来修改count], " 
            << "&count: " << Addr(count) << std::endl;
        count++;
        sleep(1);
    }
}
void* routinue2(void* args)
{
    (void)args;
    while(true)
    {
        std::cout << "thread - 2, cout = " << count << ", &count: " << Addr(count) << std::endl;
        sleep(1);
    }
}
int main()
{
    pthread_t tid1, tid2;
    pthread_create(&tid1, nullptr, routinue1, nullptr);
    pthread_create(&tid2, nullptr, routinue2, nullptr);

    pthread_join(tid1, nullptr);
    pthread_join(tid2, nullptr);
}
